/**
 * 通用js方法封装处理
 * Copyright (c) 2019 ruoyi
 */
import LuckyExcel from "luckyexcel";

// 从url字符串中提取url文件扩展名
export function get_url_extension(url) {
	return url.split(/[#?]/)[0].split('.').pop().trim();
}

export function asynLoad(src, isCss = false) {
  return new Promise(res => {
    let el;
    if (isCss) {
      el = document.createElement('link');
      el.rel = 'stylesheet';
      el.href = src;
    } else {
      el = document.createElement('script');
      el.src = src;
    }
    document.documentElement.appendChild(el);
    el.onload = el.onreadystatechange = function() {
      if (
        !this.readyState ||
        this.readyState == 'loaded' ||
        this.readyState == 'complete'
      ) {
        res(true);
      }
      this.onload = this.onreadystatechange = null;
    };
  });
}